<?php
App::uses('FormHelper', 'View/Helper');

class MyFormHelper extends FormHelper {

	public function input($fieldName = null, $options = array()) {
		$this->setEntity($fieldName);

		$modelKey = $this->model();
		$fieldKey = $this->field();

		if ((!isset($options['type']) || $options['type'] == 'select') && !isset($options['options'])) {
			$object = $this->_getModel($modelKey);
			if(isset($object->validate))
			{
				foreach($object->validator() as $validateField => $validateSet)
				{
					if($validateField != $fieldKey)
						continue;
					foreach($validateSet as $validateRule) {
						if($validateRule->rule[0] != 'inList')
							continue;

						$options['type'] = 'select';
						if($validateRule->isEmptyAllowed())
							$options['options'][''] = '';
						foreach($validateRule->rule[1] as $value)
							$options['options'][$value] = __($value, true);
					}
				}
			}
		}

		return parent::input($fieldName, $options);
	}
}
